package top.superflow.version.compare

import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
import top.superflow.validate.GeneralValidator
import top.superflow.version.compare.suggestion.{Comparer, Suggestion}
import top.superflow.version.structure.Structure

@Component
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
class StructureComparer extends Comparer [Structure, Suggestion] with GeneralValidator{


  def compare(dbStructure : Structure, appStructure : Structure): Suggestion = {
    notNull(dbStructure)
    notNull(appStructure)

    val optionalSuggestion = appStructure.compare(dbStructure)
    if(optionalSuggestion.isEmpty){
      return null
    }

    optionalSuggestion.get
  }

}
